package com.unit10.utils;
//该包用来装工具类

import java.sql.Connection;
import java.sql.DriverManager;

/**
 * 看注释参考unit8中的utils包
 */



public class GetConnection {

    private static String url = "jdbc:mysql://127.0.0.1:3306/emp?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC&useSSL=false";
    private static String dataBaseName="root";
    private static String dataBasePwd="root";

    public static Connection getConn(){
        Connection conn=null;//新建Connection对象
        try {

            Class.forName("com.mysql.cj.jdbc.Driver");//加载jdbc引擎
            conn= DriverManager.getConnection(url,dataBaseName,dataBasePwd);//获取数据库连接对象
//            System.out.println("连接成功!");
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("boom!");
        }
        return conn;
    }
//    public static void main(String[] args) {
//        GetConnection dbUtil=new GetConnection();
//        try {
//            GetConnection.getConn();
//            System.out.println("数据库连接成功！");
//        } catch (Exception e) {
//
//            e.printStackTrace();
//            System.out.println("数据库连接失败");
//        }
//    }



}